package com.ruoyi.shop.systematic.merchant.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.mall.common.domain.DtsMerchantApplication;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.shop.systematic.merchant.service.IDtsMerchantApplicationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 商户申请审核Controller
 *
 * @author ruoyi
 * @date 2025-04-24
 */
@RestController
@RequestMapping("/systematic/merchant")
public class DtsMerchantApplicationController extends BaseController
{
    @Autowired
    private IDtsMerchantApplicationService dtsMerchantApplicationService;

    /**
     * 查询商户申请审核列表
     */
    @PreAuthorize("@ss.hasPermi('systematic:merchant:list')")
    @GetMapping("/list")
    public TableDataInfo list(DtsMerchantApplication dtsMerchantApplication)
    {
        startPage();
        List<DtsMerchantApplication> list = dtsMerchantApplicationService.selectDtsMerchantApplicationList(dtsMerchantApplication);
        return getDataTable(list);
    }

    /**
     * 导出商户申请审核列表
     */
    @PreAuthorize("@ss.hasPermi('systematic:merchant:export')")
    @Log(title = "商户申请审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DtsMerchantApplication dtsMerchantApplication)
    {
        List<DtsMerchantApplication> list = dtsMerchantApplicationService.selectDtsMerchantApplicationList(dtsMerchantApplication);
        ExcelUtil<DtsMerchantApplication> util = new ExcelUtil<DtsMerchantApplication>(DtsMerchantApplication.class);
        util.exportExcel(response, list, "商户申请审核数据");
    }

    /**
     * 获取商户申请审核详细信息
     */
    @PreAuthorize("@ss.hasPermi('systematic:merchant:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dtsMerchantApplicationService.selectDtsMerchantApplicationById(id));
    }

    /**
     * 新增商户申请审核
     */
    @PreAuthorize("@ss.hasPermi('systematic:merchant:add')")
    @Log(title = "商户申请审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DtsMerchantApplication dtsMerchantApplication)
    {
        return toAjax(dtsMerchantApplicationService.insertDtsMerchantApplication(dtsMerchantApplication));
    }

    @PreAuthorize("@ss.hasPermi('systematic:merchant:opinionUpdate')")
    @Log(title = "商户申请审核", businessType = BusinessType.UPDATE)
    @PutMapping("/opinionUpdate")
    public AjaxResult opinionUpdate(@RequestBody DtsMerchantApplication dtsMerchantApplication)
    {
        return toAjax(dtsMerchantApplicationService.updateOpinion(dtsMerchantApplication));
    }

    /**
     * 修改商户申请审核
     */
    @PreAuthorize("@ss.hasPermi('systematic:merchant:edit')")
    @Log(title = "商户申请审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DtsMerchantApplication dtsMerchantApplication)
    {
        return toAjax(dtsMerchantApplicationService.updateDtsMerchantApplication(dtsMerchantApplication));
    }

    /**
     * 删除商户申请审核
     */
    @PreAuthorize("@ss.hasPermi('systematic:merchant:remove')")
    @Log(title = "商户申请审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dtsMerchantApplicationService.deleteDtsMerchantApplicationByIds(ids));
    }
}
